<template>
	<div class="entry_container">
		<k-header headTitle="登录" goBack="true"></k-header>
		<div :class="headIos?'archieve_container-ios':'entry_content'">
			<img src="../../assets/img/user/setting.png" style="width:81%;margin:15px auto 0px;display: block;"/>
			<div class="set_phone">
				<input v-if="!pvisiable" class="entry-phone _input" type="password" v-model="inputpheno" maxlength="12" placeholder="请输入6-12位的密码">
				<input v-if="pvisiable" class="entry-phone _input" type="text" v-model="inputpheno" maxlength="12" placeholder="请输入6-12位的密码">
				<i v-if="pvisiable" @click='pvis' class="pvisiable"></i>
				<i v-if="!pvisiable" @click='pinvis' class="pinvisiable"></i>
			</div>
			<div class="set_pass">
				<input v-if="!visiable" type="password" v-model="inputdata" class="entry-pass _input" maxlength="12" placeholder="请再次输入密码"/>
				<input v-if="visiable" type="text" v-model="inputdata" class="entry-pass _input" maxlength="12" placeholder="请再次输入密码"/>
				<i v-if="visiable" @click='vis' class="visiable"></i>
				<i v-if="!visiable" @click='invis' class="invisiable"></i>
			</div>
			<toast v-model="showPositionValue" type="text" width="100%" :time="1800" is-show-mask :text="message" position="bottom"></toast>
			<button :disabled="idendiss" :class="{'disable':idendiss}" @click="_idendiss" class="entry_prsee">重设密码</button>
		</div>
	</div>
</template>

<script>
	import kHeader from '../common/head';
	import util from '../../libs/util';
	import { Toast} from 'vux';
	export default {
        data () {
            return {
            	visiable:false,
            	seen:false,
            	pvisiable:false,
            	pseen:false,
            	inputdata:"",
            	inputpheno:"",
            	idendiss:false,
            	showPositionValue:false,
            	message:'',
							code:'',
							headIos:false,
            }
        },
        created(){
					if (window.navigator.userAgent.indexOf('LBLSIOS') > -1) {
						this.headIos = true
					} else {
						this.headIos = false
					};
        	this.code = this.$cookie.get('uuidCode');
        },
        components: {
        	kHeader,
        	Toast
        },
        methods:{
					vis : function () {
	          	this.visiable = !this.visiable;
	          	this.seen = !this.seen;
	        },
	        invis : function () {
	          	this.visiable = !this.visiable;
	          	this.seen = !this.seen;
	        },
	        pvis : function () {
	          	this.pvisiable = !this.pvisiable;
	          	this.pseen = !this.pseen;
	        },
	        pinvis : function () {
	          	this.pvisiable = !this.pvisiable;
	          	this.pseen = !this.pseen;
	        },
	        _idendiss : function () {
	        	this.idendiss = true;
	        	var url='/lblsapp-h5/v2/account/resetpwd.json';
	        	var data={code:this.code,password:this.inputpheno,passwordAgain:this.inputdata};
				var regtel = /^.{6,12}$/ ;
        		let isinputpheno = regtel.test(this.inputpheno);
        		let ispasswordAgain = regtel.test(this.inputdata);
	        	if(isinputpheno && ispasswordAgain){
	        		var that = this;
	        		if(this.inputpheno===this.inputdata){
	        			util.ajax.post(url, data).then(function(data){
	        				console.log(data,123345);
	        				if(data.data.code==='0'){ 
	        					that.$router.push({ path: '/entrypass'});
	        				}else{
	        					that.idendiss = false;
	        					that.message = data.data.res.msg;
	        		 			that.showPositionValue=true;	
	        				};
	        			}).catch(function(error){
	        				console.log(error)
	        			})
	        		}else{
	        			that.idendiss = false;
	        			that.message = '两次密码不一致，请重新查看。';
	    		 		that.showPositionValue=true;
	        		}
	        	}else{
	        		this.idendiss = false;
	        		this.message = '密码格式不正确。';
    		 		this.showPositionValue=true;
	        	}
	        }
        },
        
    }
</script>

<style>
	.entry_container{
		background: #ffffff;
     	/* padding-top: 45px; */
    }
    .entry_content{
    	padding: 0 8%;
    	position: relative;
    }
    
    .entry-phone{
    	margin-bottom: 1px;
    }
    .entry-pass{
    	margin-top: 1px;
    }
    .set_phone{
    	position: relative;
    }
    .set_pass{
    	position: relative;
    }
    .visiable{
    	z-index: 9;
	    position: absolute;
	    top: 16px;
	    right: 11.7%;
	    width: 24px;
	    height: 14px;
	    background-size: 24px 14px;
	    background-position: center center;
    	background-image: url(../../assets/img/user/visiable.png); 
    }
    .invisiable{
    	z-index: 9;
    	position: absolute;
    	top: 16px;
    	right: 11.7%;
    	width: 24px;
    	height: 12px;
    	background-size: 24px 12px;
    	background-position: center center;
    	background-image: url(../../assets/img/user/invisiable.png); 
    }
    .pvisiable{
    	z-index: 9;
	    position: absolute;
	    top: 16px;
	    right: 11.7%;
	    width: 24px;
	    height: 14px;
	    background-size: 24px 14px;
	    background-position: center center;
    	background-image: url(../../assets/img/user/visiable.png); 
    }
    .pinvisiable{
    	z-index: 9;
    	position: absolute;
    	top: 16px;
    	right: 11.7%;
    	width: 24px;
    	height: 12px;
    	background-size: 24px 12px;
    	background-position: center center;
    	background-image: url(../../assets/img/user/invisiable.png); 
    }
    .lookiden{
    	display: inline-block;
    	margin: 24px 0 14px 0;
    	float: right;
    	color: #808080;
    	font-size: 12px;
    }
    .error{
    	display: block;
    	font-size: 1rem;
		color: #F83E21;
    }
</style>